<template>
	<view>
		<view class="head-box">
			<view class="search-box">
				<view class="search-content">
					<uni-icons type="search" size="28" color="#c1c1c1"></uni-icons>
					<input class="search-input" type="text" :placeholder="'运单号,'+tabs[current].title+'件人姓名(电话)'" />
					<!-- <uni-icons type="scan" size="28" color="#c1c1c1"></uni-icons> -->
				</view>
			</view>
			<view class="tabs-box">
				<view class="tab" :class="{active: index == current}" v-for="(item, index) in tabs"
					:key="item.title" @click="setCurrent(index)">
					{{ item.title }}({{item.number}})
				</view>
			</view>
		</view>
		<view class="container">
			<view v-for="item in list" :key="item.id" class="card cart-box">
				<view class="head-box">
					<view class="order">
						运单号：<text class="number">{{ item.jijiancg }}</text>
					</view>
					<view class="copy" @tap.stop="copy" :data-text="item.jijiancg">
						复制
					</view>
				</view>
				<view class="info-box">
					<view class="sending">
						<view class="from-to">
							<view class="area">
								{{ item.facity }}
							</view>
							<view class="name">
								{{ item.fuser }} {{item.jmobile}}
							</view>
						</view>
						<view class="status">
							<image class="right" src="/static/index/right.png"></image>
						</view>
						<view class="from-to">
							<view class="area">
								{{ item.shoucity }}
							</view>
							<view class="name">
								{{ item.suser }} {{item.smobile}}
							</view>
						</view>
					</view>
					<view class="list">
						<view class="list-item">
							系统单号：{{ item.order_sn }} <text @tap.stop="copy" :data-text="item.order_sn">复制</text>
						</view>
						<view class="list-item">
							下单时间：{{ item.create_time_text }}
						</view>
					</view>
				</view>
				<!-- <view class="foot-box">
					<view class="button" @click="onDelete(item.id)">
						删除订单
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>
<script>
	var app = getApp();
	export default {
		data() {
			return {
				tabs: [{
						title: '寄',
						number: 0,
					},
					{
						title: '收',
						number: 0,
					}
				],
				list: [
				// 	{
				// 	jijiancg:'1',
				// 	facity:'南昌市',
				// 	fuser:'王先生',
				// 	jmobile:'18146629147',
				// 	shoucity:'上海市',
				// 	suser:'李四毛',
				// 	smobile:'18146629148',
				// 	order_sn:'33430548',
				// 	create_time_text:'2024年5月23日21:25:35'
				// },
				],
				current:0
			};
		},
		onLoad: function() {
			this.getDateList();
		},
		onReachBottom() {
			if (this.page * this.limit >= this.total) return
			if (this.isloading) return
			// 让页码值自增+1
			this.page++
			this.getDateList()
		},
		onPullDownRefresh() {
			this.page = 1;
			this.list = [];
			this.getDateList(() => uni.stopPullDownRefresh())
		},
		methods: {
			getDateList(cb) {
				let that = this;
				app.post('ApiKuaidi/selectOrderUse', {
					page:that.page,
					limit:that.limit,
					order_no:that.order_no,
					status:that.current
				}, function(res) {
					cb && cb();
					app.showLoading(false);
					that.loading = false;
					if (res.code == 0) {
						that.list.push(...res.data);
						that.total = res.count;
					}
					that.loaded();
				});
			},
			setCurrent(index){
				this.current = index;
				this.page = 1;
				this.list = [];
				this.getDateList(() => uni.stopPullDownRefresh())
			},
		}
	};
</script>
<style lang="scss" scoped>
	.head-box {
		background-color: #fff;

		.search-box {
			padding: 60rpx 30rpx 20rpx;

			.search-content {
				display: flex;
				align-items: center;
				height: 80rpx;
				padding: 0 30rpx;
				background-color: #f2f4f8;
				border-radius: 80rpx;
				column-gap: 24rpx;

				.search-icon {
					font-size: 42rpx;
					color: #000;
				}

				.search-input {
					font-size: 30rpx;
					color: #000;
					flex: 1;
				}
			}
		}

		.tabs-box {
			display: flex;
			height: 120rpx;
			line-height: 120rpx;

			.tab {
				width: 240rpx;
				font-size: 30rpx;
				color: #000;
				text-align: center;

				&.active {
					color: #ff9966;
					font-weight: 600;
					border-bottom: 6rpx solid #ff9966;
				}
			}
		}
	}

	.container {
		padding: 20rpx;

		.cart-box {
			overflow: hidden;

			&:not(:first-child) {
				margin-top: 20rpx;
			}

			.head-box {
				display: flex;
				align-items: center;
				padding: 30rpx 20rpx;
				font-size: 30rpx;
				column-gap: 20rpx;
				border-bottom: 2rpx solid #eeeeee;

				.order {
					color: #2c2c2c;

					.number {
						color: #ff6600;
					}
				}

				.copy {
					color: #999999;
					font-size: 24rpx;
				}
			}

			.info-box {
				display: flex;
				flex-direction: column;
				row-gap: 40rpx;
				padding: 10rpx 30rpx;

				.sending {
					display: flex;
					justify-content: space-around;
					align-items: center;
					column-gap: 20rpx;
					margin-top: 20rpx;

					.from-to {
						display: flex;
						flex-direction: column;
						align-items: center;
						row-gap: 12rpx;

						.area {
							font-size: 38rpx;
							color: #2c2c2c;
							font-weight: 600;
						}

						.name {
							max-width: 240rpx;
							color: #999999;
							font-size: 24rpx;
							word-break: break-word;
							text-align: center;
						}
					}

					.status {
						display: flex;
						flex-direction: column;
						align-items: center;

						.right {
							width: 120rpx;
							height: 80rpx;
						}
					}
				}

				.list {
					&-item {
						padding: 8rpx 0;
						color: #999999;
					}
				}
			}

			.foot-box {
				display: flex;
				justify-content: flex-end;
				column-gap: 20rpx;
				padding: 20rpx;

				.button {
					width: 180rpx;
					height: 68rpx;
					line-height: 68rpx;
					text-align: center;
					color: #000000;
					background-color: #f5f5f5;
					font-size: 30rpx;
					border-radius: 34rpx;
				}
			}
		}
	}
	.card {
	    border-radius: 20rpx;
	    background-color: #fff;
	}
</style>